<?php

/*
 * @copyright :     Ienter asia Technologies
 * @author :        Quyet
 * @version         v.1.0
 * @created         18/6/2014
 * @Description :   Controller error
 */
session_start();
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Mod_error extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this->load->library('session');
        $lang = $this->session->userdata('lang');
        if ($lang == "jp") {
            $this->lang->load('jp', 'japanese');
        }
        if ($lang == "en") {
            $this->lang->load('en', 'english');
        }
        if ($lang == "") {
            $this->lang->load('jp', 'japanese');
            $this->session->set_userdata('lang', 'jp');
        }
    }

    public function index() {
        if (isset($_SESSION['errorPage'])) {
            $errorPage = $_SESSION['errorPage'];
            $messages = $errorPage['message'];
            $message = is_array($messages)?$messages[0]:$messages;
            unset($_SESSION['errorPage']);
        } else {
            $message = $this->lang->line('MC016');
        }

        $data = array(
            'title' => $this->lang->line('MC016'),
            'message' => $message,
            'show' => 'errorpage',
            'data' => ''
        );
        $this->load->view('layout', $data);
    }

    public function errorPage() {
        $this->index();
    }

}

?>